package com.ryskoo.catering.productattr.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.productattr.domain.ProductAttrPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class ProductAttrRedisImpl extends BasicRedisImpl<ProductAttrPO> implements IProductAttrRepository{

    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private IProductAttrRepository productAttrRepository;
    @PostConstruct
    public void init(){
        this.setDao(productAttrRepository);
        this.setRedisClient(redisClient);
    }

    public ProductAttrRedisImpl() {
        super(HCLCacheConstant.HCL_PRODUCTATTR_KEY);
    }

    @Override
    public List<String> getUuidsByMainUuid(String mainUUid) {
        return productAttrRepository.getUuidsByMainUuid(mainUUid);
    }

    @Override
    public List<ProductAttrPO> getAttrsByMainUuid(String mainUuid) {
        return productAttrRepository.getAttrsByMainUuid(mainUuid);
    }

    @Override
    public List<String> getUuidsByMainUuids(List<String> mainUuids) {
        return productAttrRepository.getUuidsByMainUuids(mainUuids);
    }
}
